package com.miplus.ccrm.core.service.crd;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.base.MPJBaseServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.miplus.ccrm.common.JPubUtils;
import com.miplus.ccrm.core.controller.vo.credit.CrdAmortReqVo;
import com.miplus.ccrm.core.controller.vo.credit.CrdAmortResVo;
import com.miplus.ccrm.core.pojo.CreditAccountAmort;
import com.miplus.ccrm.core.mapper.CreditAccountAmortMapper;
import org.springframework.stereotype.Service;

/**
* @author pc
* @description 针对表【credit_account_amort(信用卡催收分期信息表)】的数据库操作Service实现
* @createDate 2024-04-02 20:58:43
*/
@Service
public class CreditAccountAmortServiceImpl extends MPJBaseServiceImpl<CreditAccountAmortMapper, CreditAccountAmort>
    implements CreditAccountAmortService{

    @Override
    public IPage<CrdAmortResVo> crdAmortList(CrdAmortReqVo paras)
    {
        return selectJoinListPage(new Page<>(paras.getPageNum(), paras.getPageSize()),
                CrdAmortResVo.class,
                new MPJLambdaWrapper<CreditAccountAmort>()
                        .selectAs("(select n.dsc from sys_names n where n.tid='CREDIT.AMORT.TYPE' and n.id=t.amort_type)", CrdAmortResVo::getAmortTypedsc)
                        .selectAs("(select n.dsc from sys_names n where n.tid='CREDIT.AMORT.STATUS' and n.id=t.amort_pay_status)", CrdAmortResVo::getAmortPayStatusdsc)
                        .selectAll(CreditAccountAmort.class)
                        .eq(CreditAccountAmort::getAcct,paras.getAcctno())
                        .in(CreditAccountAmort::getAmortPayStatus,"A","N")
                        .orderByAsc(CreditAccountAmort::getAmortDt)
        );
    }
}




